<?php
	PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/comment.css\" rel=\"stylesheet\">");
	PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/postview.css\" rel=\"stylesheet\">");
	PageUtil::addVar("title",$post[0]['title']." - www.Truck.co.th");
	PageUtil::addVar("keywords",$metaKeyword);
	PageUtil::addVar("description",mb_substr(strip_tags($post[0]['content']),0,120));
?>

<?php $usr_data = $this->session->userdata("user_data"); ?>
<!-- tiny mce -->
<script src="<?php echo base_url('/themes/Theme01/js/tinymce/tinymce.dev.js'); ?>"></script>
<script>
  tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    menubar : false,
    plugins: [
      "advlist autolink  image lists charmap print preview hr anchor pagebreak spellchecker",
      "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
      "save table contextmenu directionality emoticons template paste textcolor importcss"
    ],
    add_unload_trigger: false,
    toolbar: "insertfile undo redo | bold italic | alignleft aligncenter alignright alignjustify | forecolor fullpage backcolor  preview  ",
    image_advtab: true,
    style_formats: [
      {title: 'Bold text', format: 'h1'},
      {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
      {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
      {title: 'Example 1', inline: 'span', classes: 'example1'},
      {title: 'Example 2', inline: 'span', classes: 'example2'},
      {title: 'Table styles'},
      {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
  });
</script>
<!-- end tiny mce -->
<!-- style image galery box swipe  -->
	<link href="<?php echo $jspath.'/photoswipe/photoswipe.css'; ?>" type="text/css" rel="stylesheet" />
	<script type="text/javascript" src="<?php echo $jspath.'/photoswipe/lib/klass.min.js'; ?>"></script>
	<script type="text/javascript" src="<?php echo $jspath.'/photoswipe/code.photoswipe.jquery-3.0.5.min.js'; ?>"></script>
	<script type="text/javascript">
		(function(window, $, PhotoSwipe){
			$(document).ready(function(){
				var options = {
					imageScaleMethod: "fitNoUpscale"
				};
				$(".gallery a").photoSwipe(options);
			});
		}(window, window.jQuery, window.Code.PhotoSwipe));
	</script>
<!-- end -->

<script type="text/javascript">
$(function (){
	$('.imggroup').mouseover(function() {
		var src =	$(this).parent("a").data("image");
		var src2 =	$(this).parent("a").attr("href");
		var show = $(this).attr("class");
	  $('#large_image').html('<div class="gallery"><a href="'+src2+'"><img src="'+src+'" alt="หมวดหมู่ : ภาพหน้าปก" /></a></div>');
	  (function(window, $, PhotoSwipe){
			$(document).ready(function(){
				var options = {
					imageScaleMethod: "fitNoUpscale"
				};
				$(".gallery a").photoSwipe(options);
			});
		}(window, window.jQuery, window.Code.PhotoSwipe));
	});
});
</script>

<section class="container_pos allcontainer">
	<nav class="left_content breadcrumb">
		<?php echo $breadcrumb;?>
	</nav>
	<section class="container_left">
		<section class="container img_container padding5px">
			<section class="title">
				<a href="<?php echo base_url("post/view/".$post[0]['url']);?>">
					<h1>
				<?php echo $post[0]['title'];?>
					</h1>
				</a>
			</section>
			<div class="fb-like" style="margin-top:5px;" data-href="<?php echo base_url("post/view/".$post[0]['url']);?>" data-width="428px" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
					
			<section class="img">
					<?php
						if(!empty($imgs)){
							$firstImg = false;
							foreach($imgs as $key => $img) :
								if($img['firstimage'] == 1){
									$firstImg = true;
								?>
									<div id="large_image">
										<div class="gallery"><!-- use jqly image-->
											<a href="<?php echo base_url($img['filepath']);?>"><img src="<?php echo base_url($img['medium']);?>" alt="<?php echo $post[0]['title'];?>" /></a>
										</div>
									</div>
							<?php
								}
							endforeach;
							if(!$firstImg){
								?>
									<a href="<?php echo base_url($imgs[0]['filepath']);?>"><img src="<?php echo base_url($imgs[0]['medium']);?>" alt="<?php echo $post[0]['title'];?>" /></a>
								<?php
								unset($imgs[0]);
							}
						}else{
						echo "<img src=\"".$imagepath."/not_available.jpg\"/>";
						}

					?>
					<!-- tam mai del sestion  -->
					<div id="group">
						<div class="gallery" >
						<?php if(!empty($image1)) { ?>
						<section class="title">สภาพภายนอก</section>
						<?php
								foreach($image1 as $key => $img1) :
						?>
									<a href="<?php echo base_url($img1[0]['filepath']);?>" data-image="<?php echo base_url($img1[0]["medium"]); ?>"><img src="<?php echo base_url($img1[0]['small']);?>"  class="imggroup" alt="<?php echo $post[0]['title'];?> : สภาพภายนอก"/> </a>
						<?php
								endforeach;
							}
						?>

						<?php if(!empty($image2)) { ?>
							<section class="title">สภาพภายในหัวเก๋ง</section>
							<?php
								foreach($image2 as $key => $img2) :
							?>
										<a href="<?php echo base_url($img2[0]['filepath']);?>" data-image="<?php echo base_url($img2[0]["medium"]); ?>"><img src="<?php echo base_url($img2[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพภายใน" class=" imggroup "/> </a>
							<?php
								endforeach;
							}
						?>

						<?php if(!empty($image3)) { ?>
							<section class="title">สภาพคัสซี</section>
							<?php
								foreach($image3 as $key => $img3) :
							?>
										<a href="<?php echo base_url($img3[0]['filepath']);?>" data-image="<?php echo base_url($img3[0]["medium"]); ?>"><img src="<?php echo base_url($img3[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพแชสซี" class=" imggroup "/></a>
							<?php
								endforeach;
							}
						?>

						<?php if(!empty($image4)) { ?>
							<section class="title">สภาพเครื่องยนต์</section>
						 <?php
								foreach($image4 as $key => $img4) :
							?>

										<a href="<?php echo base_url($img4[0]['filepath']);?>" data-image="<?php echo base_url($img4[0]["medium"]); ?>"><img src="<?php echo base_url($img4[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพเครื่องยน" class=" imggroup "/> </a>

							<?php
								endforeach;
							}
						?>

						<?php if(!empty($image5)) { ?>
							<section class="title">สภาพช่วงล่าง</section>
						 	<?php
								foreach($image5 as $key => $img5) :
							?>
									<a href="<?php echo base_url($img5[0]['filepath']);?>" data-image="<?php echo base_url($img5[0]["medium"]); ?>"><img src="<?php echo base_url($img5[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพช่วงล่าง" class=" imggroup "/> </a>
							<?php
								endforeach;
							}
						?>

						<?php if(!empty($image6)) { ?>
							<section class="title">สภาพยาง</section>
						  <?php
								foreach($image6 as $key => $img6) :
							?>
										<a href="<?php echo base_url($img6[0]['filepath']);?>" data-image="<?php echo base_url($img6[0]["medium"]); ?>"><img src="<?php echo base_url($img6[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพยาง" class=" imggroup "/> </a>
							<?php
								endforeach;
							}
						?>

						<?php if(!empty($image7)) { ?>
							<section class="title">สภาพอุปกรเสริมอื่นๆ</section>
						  <?php
								foreach($image7 as $key => $img7) :
							?>
										<a href="<?php echo base_url($img7[0]['filepath']);?>" data-image="<?php echo base_url($img7[0]["medium"]); ?>"><img src="<?php echo base_url($img7[0]['small']);?>" alt="<?php echo $post[0]['title'];?> : สภาพยาง" class=" imggroup "/> </a>
							<?php
								endforeach;
							}
						?>

						</div>
					</div>
				<!-- end -->
			</section>
		</section>
	</section>

	<section class="container_right">
		<section class="container_pos detail_container">

			<section class="container detail_container_price padding5px">
				<div class="code" >
					<span>รหัสประกาศ <?php echo $post[0]['code']; ?></span>
				</div>
			</section>

			<section class="container detail_container_price padding5px">
				<div class="price-block">
					<?php 
					if($type[0]['id']==9 OR $type[0]['id']==10){ ?>
						<span><?php echo $type[0]['name']; ?></span>
					<?php }else{ ?>
						<?php if(!empty($type[0]['name'])){ ?>
							<span><?php echo $type[0]['name']; ?></span>
						<?php }else { ?>
							<span>ราคา</span>
						<?php }  ?>
			  	<span><?php echo number_format(intval($postmeta['price']), 0, '.', ','); ?></span>
			  	<?php } //endif id 9 and 10 ?> 
			  </div>
			  <?php
			  if(!empty($postmeta['finance']) AND $postmeta['finance'] > 0){
			  ?>
				<div class="finance-price-block">
			  	<span>จัดไฟแนนซ์ได้</span>
			  	<span><?php echo number_format($postmeta['finance'], 0, '.', ','); ?></span>
			  </div>
			  <?php
			  }
			  ?>
			  <div class="finance-price-block-2">
			  	<span>จัดไฟแนนซ์ติดต่อ ทีมงาน Truck.co.th 081-936-0611</span>
			  </div>
			  <div class="name-block">
			  	<span>
				  	<?php
				  	if($post[0]['username'] != "truck.co.th"){
				  		echo "คุณ ";
				  	}
				  	echo $post[0]["firstname"];
				  	?>
			  	</span>
			  	<?php
			  	if(!empty($post[0]["phone"])){
			  		?>
			  		<span><?php echo substr($post[0]["phone"], 0, 3)."-".substr($post[0]["phone"], 3, 3)."-".substr($post[0]["phone"],6); ?></span>
			  		<?php
			  	}else{
			  		?>
			  		<span><?php echo substr($post[0]["mobile"], 0, 3)."-".substr($post[0]["mobile"], 3, 3)."-".substr($post[0]["mobile"],6); ?></span>
			  		<?php
			  	}
			  	?>
			  	<span class="see-all-post"><a href="<?php echo base_url('post/user/'.$post[0]['username']); ?>">ดูประกาศทั้งหมดของ <?php echo $post[0]["firstname"]; ?> คลิ๊ก!!</a></span>
			  </div>
			</section>
		</section>
		<section class="container detail_container_meta padding5px">
			<section class="title">
				<h2>ข้อมูลรถยนต์</h2>
			</section>
			<dl class="dl-horizontal dl-postmeta">
				<dt>ยี่ห้อ</dt>
				<dd><?php echo (!empty($brand[0]["name"]) ? $brand[0]["name"]:"ไม่ระบุ" );?></dd>
				<dt>รุ่น</dt>
				<dd><?php echo (!empty($model[0]["name"]) ? $model[0]["name"]:"ไม่ระบุ" );?></dd>
			  <dt>ปีจดทะเบียน</dt>
			  <dd><?php echo (!empty($postmeta["yearregister"]) ? $postmeta["yearregister"]:"ไม่ระบุ" );?></dd>
			  <dt>แรงม้า</dt>
			  <dd><?php echo (!empty($postmeta["horsepower"]) ? $postmeta["horsepower"]:"ไม่ระบุ" );?></dd>
			  <dt>เชื้อเพลิง</dt>
			  <dd><?php echo (!empty($postmeta["fuel"]) ? $postmeta["fuel"]:"ไม่ระบุ" );?></dd>
			  <dt>สินค้าอยู่ที่</dt>
			  <dd><?php echo (!empty($postmeta["province"]) ? Util::getProvince($postmeta["province"]):"ไม่ระบุ" );?></dd>
			</dl>
		</section>
		<section class="container detail_container_user padding5px">
			<section class="title">
				<h2>ข้อมูลผู้ขาย</h2>
			</section>
			<dl class="dl-horizontal dl-postmeta">
			  <dt>ชื่อ</dt>
			  <dd><?php echo $post[0]["firstname"]; ?> <?php echo $post[0]["lastname"]; ?></dd>

			  <dt>เบอร์โทรศัพท์</dt>
			  <?php
			  if(!empty($post[0]["phone"])){
			  	?>
			  	<dd><?php echo substr($post[0]["phone"], 0, 3)."-".substr($post[0]["phone"], 3, 3)."-".substr($post[0]["phone"],6); ?></dd>
			  	<?php
			  }else{
			  	?>
			  	<dd>-</dd>
			  	<?php
			  }
			  ?>
			  <dt>เบอร์มือถือ</dt>
			  <?php
			  if(!empty($post[0]["mobile"])){
			  	?>
			  	<dd><?php echo substr($post[0]["mobile"], 0, 3)."-".substr($post[0]["mobile"], 3, 3)."-".substr($post[0]["mobile"],6); ?></dd>
			  	<?php
			  }else{
			  	?>
			  	<dd>-</dd>
			  	<?php
			  }
			  ?>
			  <dt>อีเมลล์</dt>
			  <dd><a href="mailto:<?php echo $post[0]["email"];?>"><?php echo $post[0]["email"];?></a></dd>
			  <dt>ที่อยู่</dt>
			  <dd><?php echo $post[0]["address"];?></dd>
			  <dt>อำเภอ</dt>
			  <dd><?php echo $post[0]["district"];?></dd>
			  <dt>จังหวัด</dt>
			  <dd><?php echo Util::getProvince($post[0]["province"]);?></dd>
			  <dt>ไปรษณีย์</dt>
			  <dd><?php echo $post[0]["zipcode"];?></dd>
			</dl>
		</section>
<?php
	if(!empty($userdata) && ($post[0]['usr_id'] == $userdata['id'] OR $userdata['group'] == 2)){
?>
		<section class="container content_container padding5px">
			<section class="title">
				<h2>จัดการประกาศของท่าน</h2>
			</section>
			<section>
				<dl class="dl-horizontal dl-postmeta">
				  <dt style="width:300px;"><a href="<?php echo base_url('post/updatepost/'.$post[0]['id']);?>" title="อัพเดทประกาศขึ้นบน">อัพเดทประกาศขึ้นบน</a></dt>

				  <dt><a href="<?php echo base_url('post/add/'.$post[0]['id']);?>" title="แก้ไขประกาศ">แก้ไขประกาศ</a></dt>
				  <dd></dd>
				  <dt><a href="<?php echo base_url('post/del/'.$post[0]['id']);?>" title="ลบประกาศ">ลบประกาศ</a></dt>
				  <dd></dd>
				  <?php if($post[0]['typ_id']==9){ ?>
					  <dt><a href="<?php echo base_url('post/check_type/'.$post[0]['id'].'/'.'1');?>" title="แก้ไขประกาศ" class="unlock">ปลดการซื้อขาย</a></dt>
					  <dd></dd>
				  <?php }elseif($post[0]['typ_id']==10){ ?>
					  <dt><a href="<?php echo base_url('post/check_type/'.$post[0]['id'].'/'.'9');?>" title="แก้ไขประกาศ">ซื้อขายแล้ว</a></dt>
					  <dd></dd>
					  <dt><a href="<?php echo base_url('post/check_type/'.$post[0]['id'].'/'.'1');?>" title="แก้ไขประกาศ" class="unlock">ปลดการมัดจำ</a></dt>
					  <dd></dd>
				  <?php }else{ ?>
					  <dt><a href="<?php echo base_url('post/check_type/'.$post[0]['id'].'/'.'9');?>" title="แก้ไขประกาศ">ซื้อขายแล้ว</a></dt>
					  <dd></dd>
					  <dt><a href="<?php echo base_url('post/check_type/'.$post[0]['id'].'/'.'10'); ?>" title="แก้ไขประกาศ" >วางมัดจำแล้ว</a></dt>
					  <dd></dd>
				  <?php } ?>

				</dl>
			</section>
		</section>
<?php
	}

	if(!empty($userdata) AND ($userdata['group'] == 2 OR $userdata['group'] == 3) AND (!empty($postmeta["admin_name"]) OR !empty($postmeta["admin_phone"]) OR !empty($postmeta["admin_price"]) OR !empty($postmeta["admin_province"]) OR !empty($postmeta["admin_log"]))){
?>
		<section class="container detail_container_user padding5px">
			<section class="title">
				<h2>ข้อมูลผู้ขาย (สำหรับแอดมิน)</h2>
			</section>
			<dl class="dl-horizontal dl-postmeta">
			  <dt>ชื่อผู้ขาย</dt>
			  <dd><?php echo (!empty($postmeta["admin_name"]) ? $postmeta["admin_name"]:"-" );?></dd>
			  <dt>เบอร์โทร</dt>
			  <dd><?php echo (!empty($postmeta["admin_phone"]) ? $postmeta["admin_phone"]:"-" );?></dd>
			  <dt>ราคาทุน</dt>
			  <dd><?php echo (!empty($postmeta["admin_price"]) ? $postmeta["admin_price"]:"-" );?></dd>
			  <dt>จังหวัด</dt>
			  <dd><?php echo (!empty($postmeta["admin_province"]) ? $postmeta["admin_province"]:"-" );?></dd>
			  <dt>บันทึก</dt>
			  <dd><?php echo (!empty($postmeta["admin_log"]) ? $postmeta["admin_log"]:"-" );?></dd>
			</dl>
		</section>
	<?php
  }
  ?>
	</section>
	<section class="container content_container padding5px">
		<h2 class="title">คำอธิบาย</h2>
		<article>
				<?php echo $post[0]['content'];?>
		</article>
	</section>

	<section class="container content_container padding5px">
		<h2 class="title">ประกาศอื่นๆ ของ <?php echo $post[0]["firstname"]; ?> <?php echo $post[0]["lastname"]; ?></h2>
		<div class="related-body">
			<?php
				if(!empty($relatedPosts)){
	        foreach ($relatedPosts as $key => $value) {
	    ?>
	      <div class="related-list">
	        <a href="<?php echo base_url('post/view/'.$value["url"]);?>" target="_blank">
	        	<span class="related-list-title"><?php echo $value["title"];?></span>
	          <div class="related-list-image">
	            <?php
	              if(!empty($value["images"][0]["small"])){
	                ?>
	                <img src="<?php echo base_url($value["images"][0]["medium"])?>" alt="<?php echo $value["title"];?>"/>
	                <?php
	              }else{
	                ?>
	                <img src="<?php echo $imagepath."/not_available-2.jpg"?>" alt="<?php echo $value["title"];?>"/>
	                <?php
	              }
	            ?>
	          </div>
	          <div class="related-list-price"><span>ราคา</span> <span><?php echo number_format(intval($value["postMeta"]["price"]), 0, '.', ',');?>.-</span></div>
	        </a>
	      </div>
	    <?php 
	  		}
	  	}else{
	  		?>
	  		<p class="text-center">ไม่มีประกาศอื่นๆ</p>
	  		<?php
	  	}
	    ?>
		</div>
    <div class="related-footer">
	    <a href="<?php echo base_url("post/user/".$post[0]["username"]);?>" class="btn pull-right btn-primary btn-small">ดูประกาศรถทั้งหมดของ <?php echo $post[0]["firstname"]; ?> <?php echo $post[0]["lastname"]; ?> <i class="icon-arrow-right"></i></a>
	  </div>
	</section>
</section>

<section class="left_content">
<form action="<?php echo base_url('comment/add_comment'); ?>" method="post">
<section class="commentArea">
<h3>Comment</h3>
	<?php
		if($comment){
	?>

	<?php foreach($comment as $key => $value) :
	if($value['parent_id']==0  AND ($value['status'] == 1 OR $userdata['group'] == 2)){
		?>
		<section class="first_comment">
			<section class="middle_bar">
				<section class="pic_box">
					<img src="<?php echo base_url('themes/Theme01/images/user.png');?>" width="100"height="100" alt="<?php echo $value['firstname'];?>">
					<p><?php echo $value['firstname'];?></p>
				</section>
				<?php if($value['status'] == 1){ ?>   <!--Status == 1  Comment -->
				<section class="comment">
					<section class="point"></section>
						<p><?php
							$content=wordwrap($value['content'],50,"\n",TRUE);
							echo "$content\n";
						?></p>
					<section class="reply_box">
						<b><a href="<?php echo base_url('comment/reply/'.$value['id']);?>" title="ตอบกลับ">Reply</a></b>
						<?php
						if(!empty($userdata)){
							if($userdata['group']==2 OR $value['usr_id'] == $userdata['id']){
						?>
						<section class = "option_edit">
							<a href="<?php echo base_url('comment/edit_comment/'.$value['id']);?>">
							<img src ="<?php echo base_url('themes/Theme01/images/edit.png');?>"width="25" height="30" title="แก้ไขคอมเมนท์" alt="แก้ไขคอมเมนท์"></a>
						</section>
						<section class = "option_delete">
							<a href="<?php echo base_url('comment/delete_comment/'.$value['id']);?>">
								<img src ="<?php echo base_url('themes/Theme01/images/x.png');?>"width="25" height="30" title="ลบคอมเมนท์" alt="ลบคอมเมนท์"></a>
						</section>
					</section>
				</section>
						<?php
						}} }elseif($value['status'] == 0 AND $userdata['group'] == 2){    //Status == Comment Satus == 0 Admin
						?>

				<section class="commentdel">
					<section class="point"></section>
						<p><?php
							$content=wordwrap($value['content'],50,"\n",TRUE);
							echo "$content\n";
						?></p>
					<section class="reply_box">
						<b><a href="<?php echo base_url('comment/delete_comment/'.$value['id']);?>"title="ตอบกลับ">UNBAND</a></b>
					</section>
				</section>
						<?php
						}
						?>
			</section>
		<section class="second_middle_bar">
			<?php foreach ($comment as $valuereply	) {
				if($value['id']==$valuereply['parent_id']  AND ( $valuereply['status'] == 1 OR $userdata['group'] == 2)) {
			?>
				<section class="first_comment2">
					<section class="middle_bar2">
						<section class="pic_box2">
								<img src="<?php echo base_url('themes/Theme01/images/user.png');?>" width="100" height="100" alt="<?php echo $valuereply['firstname'];?>">
								<p><?php echo $valuereply['firstname'];?></p>
						</section>
						<?php if($valuereply['status'] == 1){ //comment LV 2 ?>
						<section class="comment2">
							<section class="point"></section>
							<p><?php
								$content=wordwrap($valuereply['content'],50,"\n",TRUE);
								echo "$content\n";
							?></p>

							<section class="reply_box">
								<b><a href="<?php echo base_url('comment/reply/'.$valuereply['id']);?>" title="ตอบกลับ">Reply</a></b>
								<?php
									if(!empty($userdata)){
										if($userdata['group']==2 OR $valuereply['usr_id']==$userdata['id']){
								?>
								<section class = "option_edit">
									<a href="<?php echo base_url('comment/edit_comment/'.$valuereply['id']);?>">
									<img src ="<?php echo base_url('themes/Theme01/images/edit.png');?>"width="25"height="30" title="แก้ไขคอมเม้น" alt="แก้ไขคอมเมนท์"></a>
								</section>
								<section class = "option_delete">
									<a href="<?php echo base_url('comment/delete_comment/'.$valuereply['id']);?>">
										<img src ="<?php echo base_url('themes/Theme01/images/x.png');?>"width="25"height="30" title="ลบคอมเม้น" alt="ลบคอมเมนท์"></a>
								</section>
							</section>
						</section>
								<?php
								}} }else if($valuereply['status'] == 0 AND $userdata['group']==2){  ?>
										<section class="commentdel2">
										<section class="point"></section>
											<p><?php
												$content=wordwrap($valuereply['content'],50,"\n",TRUE);
												echo "$content\n";
											?></p>
										<section class="reply_box">
											<b><a href="<?php echo base_url('comment/delete_comment/'.$valuereply['id']);?>" title="ตอบกลับ">UNBAND</a></b>
										</section>
									</section>
								<?php
								}
								?>
					</section>


					<section class="third_middle_bar">
						<?php foreach ($comment as $valuereply3	) {
							if($valuereply['id']==$valuereply3['parent_id'] AND ( $valuereply3['status'] == 1 OR $userdata['group'] == 2)) {
						?>
						<section class="first_comment3">
							<section class="middle_bar3">
								<section class="pic_box3">
									<img src="<?php echo base_url('themes/Theme01/images/user.png');?>" width="100" height="100" alt="<?php echo $valuereply3['firstname'];?>">
									<p><?php echo $valuereply3['firstname'];?></p>
								</section>
								<?php if($valuereply3['status'] == 1){ //comment LV 3?>
								<section class="comment3">
									<section class="point"></section>
										<p><?php
											$content=wordwrap($valuereply3['content'],50,"\n",TRUE);
											echo "$content\n";
										?></p>
									<section class="reply_box">
										<b><a href="<?php echo base_url('comment/reply/'.$valuereply3['id']);?>"title="ตอบกลับ">Reply</a></b>
										<?php
											if(!empty($userdata)){
												if($userdata['group']==2 OR $valuereply3['usr_id']==$userdata['id']){
										?>
										<section class = "option_edit">
											<a href="<?php echo base_url('comment/edit_comment/'.$valuereply3['id']);?>">
											<img src ="<?php echo base_url('themes/Theme01/images/edit.png');?>" width="25" height="30" title="แก้ไขคอมเม้น" alt="แก้ไขคอมเมนท์"></a>
										</section>
										<section class = "option_delete">
											<a href="<?php echo base_url('comment/delete_comment/'.$valuereply3['id']);?>">
												<img src ="<?php echo base_url('themes/Theme01/images/x.png');?>" width="25" height="30" title="ลบคอมเม้น" alt="ลบคอมเมนท์"></a>
										</section>
									</section>
								</section>
										<?php
										}} }elseif($valuereply3['status'] == 0 AND $userdata['group']==2){
										?>

										<section class="commentdel3">
										<section class="point"></section>
											<p><?php
											$content=wordwrap($valuereply3['content'],50,"\n",TRUE);
											echo "$content\n";
										?></p>
										<section class="reply_box">
											<b><a href="<?php echo base_url('comment/delete_comment/'.$valuereply3['id']);?>"title="ตอบกลับ">UNBAND</a></b>
										</section>
									</section>
										<?php
										}
										?>

							</section>
							<section class="end_middle_bar">
								<?php foreach ($comment as $valuereplys	) {
									if($valuereply3['id']==$valuereplys['parent_id'] AND ($valuereplys['status'] == 1 OR $userdata['group'] == 2)) {
								?>
								<section class="first_comments">
									<section class="middle_bars">
										<section class="pic_box3">
											<img src="<?php echo base_url('themes/Theme01/images/user.png');?>"width="100"height="100" alt="<?php echo $valuereplys['firstname'];?>">
											<p><?php echo $valuereplys['firstname'];?></p>
										</section>
										<?php if($valuereplys['status'] == 1){ //comment LV 4?>
										<section class="comments">
											<section class="point"></section>
											<p><?php
												$content=wordwrap($valuereplys['content'],50,"\n",TRUE);
												echo "$content\n";
											?></p>
											<section class="reply_box">
												<?php
													if(!empty($userdata)){
														if($userdata['group']==2 OR $valuereplys['usr_id']==$userdata['id']){
												?>
												<section class = "option_edit">
													<a href="<?php echo base_url('comment/edit_comment/'.$valuereplys['id']);?>">
													<img src ="<?php echo base_url('themes/Theme01/images/edit.png');?>" width="25" height="30" title="แก้ไขคอมเม้น" alt="แก้ไขคอมเมนท์"></a>
												</section>
												<section class = "option_delete">
													<a href="<?php echo base_url('comment/delete_comment/'.$valuereplys['id']);?>">
														<img src ="<?php echo base_url('themes/Theme01/images/x.png');?>" width="25" height="30" title="ลบคอมเม้น" alt="ลบคอมเมนท์"></a>
												</section>
												</section>
										</section>
												<?php
												}} }elseif($valuereplys['status'] == 0 AND $userdata['group']==2){
												?>

												<section class="commentdel3">
												<section class="point"></section>
													<p><?php
													$content=wordwrap($valuereplys['content'],50,"\n",TRUE);
													echo "$content\n";
												?></p>
												<section class="reply_box">
													<b><a href="<?php echo base_url('comment/delete_comment/'.$valuereplys['id']);?>"title="ตอบกลับ">UNBAND</a></b>
												</section>
												</section>




												<?php
												}
												?>

									</section>
								</section>
								<?php
								 }  }
								 ?>
					</section>
							</section>

						<?php
						 }  }
						 ?>
					</section>
				</section>

			<?php

			 }  }
			 ?>
		</section>
	</section><br/>
	<?php } endforeach; ?>
	</section>
	<?php }else{?>

<section class="alert_area">
		<section class="alert_detail">
			<p class="text-center">ยังไม่มีความคิดเห็น</p>
		</section>
</section>
<?php
}
if(!empty($usr_data)){
?>
<legend>Post new comment</legend>

<section class="box_area">
	<input type="hidden" name="pos_id"  value="<?php echo $post[0]['id'] ?>" />
	<input type="hidden" name="title"  value="<?php echo $post[0]['title'] ?>" />
  <input type="hidden" name="type"  value="post" />
<p><textarea id="elm1" name="content" cols="150" rows="10" size="100" type="text"></textarea></p><br />
<button type="submit" class="btn btn-primary" id="submitbtn">แสดงความคิดเห็น</button>
</section>
<?php
}else{
?>
<section class="alert_area">
	<section class="alert_bar">
		<p>แจ้งเตือน</p>
	</section>
		<section class="alert_detail">
			<p>ต้องการแสดงความคิดเห็นกรุณาล็อคอิน แต่ถ้ายังไม่ได้สมัครสมาชิกคลิกสมัครสมาชิก<p>
			<section class="button_log">
				<a href="<?php echo base_url('user'); ?>" ><button type="button" class="btn btn-primary">ล็อคอิน</button></a>&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url('user/register'); ?>" ><button type="button" class="btn btn-primary" id="button_reg">สมัครสมาชิก</button></a>
			</section>
		</section>
</section>
<?php
}
?>
</form>
</section>